import { homelink } from "@/api/axios.js"


export let shanpage1 = {
    state: {
        arr: [],
        arr2: [],
        arr3: []
    },
    mutations: {
        shanpage1(state, payload) {
            state.arr = payload
        },
        shanpage2(state, payload) {
            state.arr2 = payload
        },
        shanpage3(state, payload) {
            state.arr3 = payload
        }

    },
    getters: {
        newarr(state) {

            let arr = state.arr
            var len = arr.length;
            for (var i = 0; i < len - 1; i++) {
                var idx = Math.floor(Math.random() * (len - i));
                var temp = arr[idx];
                arr[idx] = arr[len - i - 1];
                arr[len - i - 1] = temp;
            }
            return arr;
        }
    },

    actions: {
        shanpage1(context) {
            homelink("/home/json", "get").then((ok) => {
                // console.log(ok.data.shanpage1)
                context.commit("shanpage1", ok.data.shanpage1)
            })
        },
        shanpage2(context) {
            homelink("/home/json", "get").then((ok) => {
                // console.log(ok.data.shanpage2)
                context.commit("shanpage2", ok.data.shanpage2)
            })
        },
        // shanpage3(context) {
        //     homelink("/home/json", "get").then((ok) => {
        //         console.log(ok.data.shanpage3)
        //         context.commit("shanpage3", ok.data.shanpage3)
        //     })
        // }


    }
}